package com.yi.wood.kafka;

import com.yi.wood.kafka.msg.ImKafkaMsg;
import org.springframework.boot.Banner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.Resource;
import java.util.Scanner;

/**
 * Created by moyi on 2019/2/19 14:30
 *  //非WEB工程
 * @author moyi
 */

@SpringBootApplication
public class WoodKafkaMain implements CommandLineRunner {

    @Resource
    private ImKafkaMsg imKafkaMsg;

    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(WoodKafkaMain.class);
        application.setBannerMode(Banner.Mode.CONSOLE);
        application.run(args);
    }

    @Override
    public void run(String... args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()){
            String line = scanner.nextLine();
            if ("quit".equalsIgnoreCase(line) || "exit".equalsIgnoreCase(line)){
                break;
            }
            imKafkaMsg.send(line);
        }
        System.exit(0);
    }
}
